package org.xian.token.util;

import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

/**
 * @author eric
 * @program spring-security-jwt-token
 * @description
 * @date 2021/12/30
 */
@Component
public class SqlUtil implements InitializingBean {

    private static final Logger log = LoggerFactory.getLogger(SqlUtil.class);


    @Override
    public void afterPropertiesSet() throws Exception {


        String sql = "CREATE TABLE eric.sys_user (\n" +
                "\tuser_id INT auto_increment NOT NULL primary key,\n" +
                "\tusername varchar(100) NULL,\n" +
                "\tpassword varchar(100) NULL,\n" +
                "\tuser_role varchar(100) NULL\n" +
                ")\n" +
                "ENGINE=InnoDB\n" +
                "DEFAULT CHARSET=utf8mb4\n" +
                "COLLATE=utf8mb4_general_ci;\n" +
                "CREATE INDEX sys_user_user_id_IDX USING BTREE ON eric.sys_user (user_id);";

        SqlRunner sqlRunner = new SqlRunner();
//        boolean insert = sqlRunner.insert(sql, null);
//        if (insert) {
//            log.info("建表成功");
//        }

    }
}
